package cn.iocoder.an.module.mold.dal.mysql.upkeeptobe;

import java.util.*;

import cn.iocoder.an.framework.common.pojo.PageResult;
import cn.iocoder.an.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.an.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.an.module.mold.dal.dataobject.upkeeptobe.UpkeepTobeDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.an.module.mold.controller.admin.upkeeptobe.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 待保养模具 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface UpkeepTobeMapper extends BaseMapperX<UpkeepTobeDO> {
    default PageResult<UpkeepTobeDO> selectPage(UpkeepTobePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UpkeepTobeDO>()
                .eqIfPresent(UpkeepTobeDO::getAccountId, reqVO.getAccountId())
                .eqIfPresent(UpkeepTobeDO::getDrawingNoId, reqVO.getDrawingNoId())
                .eqIfPresent(UpkeepTobeDO::getUpkeepId, reqVO.getUpkeepId())
                .eqIfPresent(UpkeepTobeDO::getIfTmp, reqVO.getIfTmp())
                .eqIfPresent(UpkeepTobeDO::getStatus, reqVO.getStatus())
                .eqIfPresent(UpkeepTobeDO::getTaskId, reqVO.getTaskId())
                .eqIfPresent(UpkeepTobeDO::getItemId, reqVO.getItemId())
                .betweenIfPresent(UpkeepTobeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UpkeepTobeDO::getNextUpkeepTime));
    }

    @Delete("DELETE FROM mold_upkeep_tobe WHERE id = #{id}")
    int forceDeleteById(@Param("id") Long id);
}